package prjbancoimobilitariocliente;

import controller.KeyBordJogoEventos;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import model.TAGS;
/**
 * Classe inicial da aplicação implementa o padrão de projeto Singleton
 */
public class PrjBancoImobilitarioCliente extends Application {
    private static PrjBancoImobilitarioCliente instace;
    private static Stage stage;
    
    public PrjBancoImobilitarioCliente() {
        instace = this;
    }
    
    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("/view/jogador/Index.fxml"));
        Scene scene = new Scene(root,Color.web(TAGS.COLOR_APP));
        stage = new Stage(StageStyle.TRANSPARENT);
        stage.setResizable(false);
        Screen screen = Screen.getPrimary();
        Rectangle2D bounds = screen.getVisualBounds();

        stage.setX(bounds.getMinX());
        stage.setY(bounds.getMinY());
        stage.setWidth(bounds.getWidth());
        stage.setHeight(bounds.getHeight());
        stage.getIcons().add(new Image("/resource/img/icon.png"));
        stage.setScene(scene);
        stage.show();
        stage.setTitle("TEITEI Banco Imobiliário");
        scene.setOnKeyPressed(new KeyBordJogoEventos());
        this.stage = stage;
    }
    
    public static PrjBancoImobilitarioCliente getInstace(){
        return instace;
    }
    
    public void setStage(Parent root) throws IOException{
        Scene scene = new Scene(root, Color.web(TAGS.COLOR_APP));
        scene.setOnKeyPressed(new KeyBordJogoEventos());
        Screen screen = Screen.getPrimary();
        Rectangle2D bounds = screen.getVisualBounds();
        stage.setX(bounds.getMinX());
        stage.setY(bounds.getMinY());
        stage.setWidth(bounds.getWidth());
        stage.setHeight(bounds.getHeight());
        stage.setScene(scene);
        stage.setTitle("TEITEI Banco Imobiliário");
    }

    @Override
    public void stop() throws Exception {
        System.exit(0);
        super.stop();
    }
    
    public static void main(String[] args) {
        launch(args);
    }  
}
